package com.leetcode.周赛.第235场;

/**
 * @author: xiaomi
 * @date: 2021/4/4
 * @description: 5722. 截断句子
 * https://leetcode-cn.com/contest/weekly-contest-235/problems/truncate-sentence/
 */
public class A_5722_截断句子 {
    static A_5722_截断句子 action = new A_5722_截断句子();

    public static void main(String[] args) {
        test1();
        test2();
        test3();
    }

    static void test1() {
        //

        //System.out.println("res = " + res);
    }

    static void test2() {
        //

        //System.out.println("res = " + res);
    }

    static void test3() {
        //

        //System.out.println("res = " + res);
    }

    public String truncateSentence(String s, int k) {
        String[] split = s.split(" ");
        int len = split.length;
        if (len == k) {
            return s;
        }
        StringBuilder sb = new StringBuilder();
        int index = 0;
        while (index < k) {
            sb.append(split[index++]).append(" ");

        }
        return sb.toString().trim();
    }

}
